Skip to content

fix(windows): preserve Wintun identity after restart - #7

Merged
KKRainbow merged 8 commits into
v2from
fix/wintun-stable-identity-recreation
Oct 28, 2026
Merged

KKRainbow merged 8 commits into
v2from
fix/wintun-stable-identity-recreation

Conversation

@KKRainbow

Copy link
Copy Markdown
Member

Problem

A Windows process terminated while a Wintun adapter is active can leave its fixed device instance behind. Recreating the same adapter GUID can then fail with 0xC0000035 or a device setup timeout.

Change

Trigger Wintun's existing orphan cleanup through its public open operation and wait for the requested device instance to disappear before creating it. Keep the requested GUID and reject a same-name adapter with a different GUID. This avoids an external device-removal helper and supports WOW64 on Windows 10 1809.

Wintun's cleanup is asynchronous and scans Wintun devices globally. If cleanup does not complete, the caller receives a timeout; Wintun's initial synchronous open is not covered by that polling timeout.

Verification

  • Windows 10 1809: 100 fixed-GUID forced process terminations and recreations using an i686 test process; a separate test verified another adapter received a UDP packet after 100 recreations.
  • Windows 11: 30 fixed-GUID forced terminations and recreations, plus same-name GUID mismatch coverage.
  • Windows 10 1809: EasyTier x64 with this working-tree change, fixed name and static IPv4, 100/100 forced-restart cycles with the same GUID.
  • Windows 11: the same EasyTier scenario passed 20/20 cycles with the same GUID.
  • cargo fmt --all -- --check; Windows x86 and x64 Clippy with existing lint exceptions; Linux library tests in the rust container (2 passed).

Windows 11's UDP probe was blocked or otherwise affected by a host outbound firewall rule; its exact cause was not verified. The rust-tun repository's strict Clippy has existing unrelated lint failures and full cargo test has existing examples using the old tun2 crate name.

Related: EasyTier/EasyTier#2770

Wait for Wintun's orphan cleanup after opening the adapter, then
recreate the requested identity only after its device node disappears.
This avoids unsupported WOW64 uninstall commands and preserves GUIDs.

Reject a same-name adapter with a different GUID, and cover adapter
identity and other-adapter traffic in the Windows tests.
@KKRainbow
KKRainbow merged commit ac0c674 into v2 Oct 28, 2026
4 of 16 checks passed
zzxym pushed a commit to zzxym/rust-tun that referenced this pull request Nov 14, 2026
Wait for Wintun's orphan cleanup after opening the adapter, then
recreate the requested identity only after its device node disappears.
This avoids unsupported WOW64 uninstall commands and preserves GUIDs.

Reject a same-name adapter with a different GUID, and cover adapter
identity and other-adapter traffic in the Windows tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant